package com.cskaoyan.javase.oop1._6bigexercise._1pvz;

/**
 * @description: 植物类
 * @author: wuguidong@cskaoyan.onaliyun.com
 **/

/**
 * 为了完成植物和僵尸的交互,它们必须持有互相的引用作为成员变量,去方便完成交互
 *
 */
public class Plant {
    //属性
    String name;
    int hp;
    int damage; //攻击力

    //持有僵尸对象的引用
    Zombie z;

    //行为
    public void attack() {
        System.out.println("我攻击了" + z.name);
    }

    public void beingAttacked() {
        System.out.println("我被" + z.name + "攻击了,还剩下" + (this.hp - z.damage) + "点血量!");
    }

    //构造方法

    public Plant() {
    }

    public Plant(String name, int hp, int damage) {
        this.name = name;
        this.hp = hp;
        this.damage = damage;
    }
}
